package com.example.makedata.service;

import cn.hutool.poi.excel.ExcelUtil;
import com.google.common.base.Stopwatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.concurrent.TimeUnit;

/**
 * @author lilu
 * @Date 2019/6/13
 */
@Service
public class DataService {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    JdbcTemplate jdbcTemplate;

    public  void dealData(){
        logger.info("开始处理数据");
        Stopwatch timeCounter = Stopwatch.createStarted();
        InputStream resourceAsStream = this.getClass().getResourceAsStream("/618演示账号数据20190610.xlsx");
        ExcelUtil.readBySax(resourceAsStream, 1, (sheetIndex, rowIndex, rowlist) -> {
            if (rowIndex==0) return;
            //数据处理

        });

        logger.info("完成数据处理,耗时：{}秒",timeCounter.elapsed(TimeUnit.SECONDS));





    }


}
